Overview
Most candidates cannot solve this interview problem:
— Alexey Grigorev (@Al_Grigor) February 3, 2021
🔸 Input: "aaaabbbcca"
🔸 Output: [("a", 4), ("b", 3), ("c", 2), ("a", 1)]
Write a function that converts the input to the output
I ask it in the screening interview and give it 25 minutes
How would you solve it?
Coding Challenge
Not a fan of coding challenges, but this one looked interesting. I gave myself 25 minutes to figure it out and it took me about 25 minutes to come up with a solution.
My first couple of attempts where trying to be too clever. I just came to the conclusion that I should be writing it out in a simple way with comments.
Final
The solution gist is not the cleanest but I don’t mind it. May not be the most swifty way of doing this but it’s straightforward to read. You can see where the logic goes and nothing is hidden.